home *** CD-ROM | disk | FTP | other *** search
/ SPACE 2 / SPACE - Library 2 - Volume 1.iso / utility / 611 / pathtran / pathtran.c next >
C/C++ Source or Header  |  1992-06-17  |  2KB  |  119 lines

  1. #include <tosdefs.h>
  2. #include <osbind.h>
  3.  
  4. #define FALSE 0
  5. #define TRUE 1
  6.  
  7. extern long *_base;
  8. extern my_gemdos();
  9.  
  10. int (*sys_gemdos)();
  11.  
  12. #ifdef DEBUG
  13. #define FDEBUG
  14. #define EXEC
  15. #endif
  16.  
  17. static char bugbuf[132];
  18.  
  19. static char pathbuf[256];
  20.  
  21. char *xlatpath(s)
  22. register char *s;
  23. {
  24.     register char *p;
  25.  
  26.     for (p = pathbuf; *s; p++)
  27.         if ((*p = *s++) == '/')
  28.             *p = '\\';
  29.     *p = 0;
  30.     return(pathbuf);
  31. }
  32.  
  33. xlatarg(path)
  34. char **path;
  35. {
  36.     *path = xlatpath(*path);
  37. }
  38.  
  39. struct exec_frame {
  40.     int ef_mode;
  41.     char *ef_path;
  42.     char *ef_tail;
  43.     char *ef_env;
  44. };
  45. extern long xexec();
  46.  
  47. pexec(pf)
  48. struct exec_frame *pf;
  49. {
  50.     pf->ef_path = xlatpath(pf->ef_path);
  51. }
  52.  
  53. frename(p)
  54. struct {
  55.     int fr_n;
  56.     char *fr_old;
  57.     char *fr_new;
  58. } *p;
  59. {
  60. static char path1[256];
  61.  
  62.     strcpy(path1, xlatpath(p->fr_old));
  63.     p->fr_old = path1;
  64.     p->fr_new = xlatpath(p->fr_new);
  65. }
  66.  
  67. /* 
  68.  ***************** END OF GEMDOS HANDLERS ***************
  69.  */
  70.  
  71.  
  72. /*
  73.  * dispatch GEMDOS function
  74.  */
  75.  
  76. do_gemdos(n, p)
  77. int n;
  78. char *p;
  79. {
  80. #ifdef PALL
  81.  if (n != 0xb) {
  82.   sprintf(bugbuf, "BDOS: '%s' %02x\n\r", runningpcb->name, n);
  83.   bugws(bugbuf);
  84.  }
  85. #endif
  86.     switch (n) {
  87.     case 0x3b:        /* 3b Dsetpath */
  88.     case 0x3c:        /* 3c Fcreate */
  89.     case 0x3d:        /* 3d Fopen */
  90.     case 0x41:        /* 41 Fdelete */
  91.     case 0x4e:        /* 4e Fsfirst */
  92.         xlatarg(p);
  93.         break;
  94.     case 0x4b:        /* 4b Pexec */
  95.         pexec(p);
  96.         break;
  97.     case 0x56:        /* 56 Frename */
  98.         frename(p);
  99.         break;
  100.     }
  101. }
  102.  
  103.         
  104. bugws(s)
  105. char *s;
  106. {
  107.     while (*s) 
  108.         Bconout(2, *s++);
  109. }
  110.  
  111.  
  112. main()
  113. {
  114.     Cconws("Slashman - Path Translator.\r\n(C) 1992 David Beckemeyer\r\nFREEWARE\r\n");
  115.      sys_gemdos = Setexc(0x21, my_gemdos);
  116.     Ptermres((long)(_base[3] + _base[5] + _base[7] + 0x100L), 0);
  117.     Setexc(0x21, sys_gemdos);
  118. }
  119.